#pragma once
#include "IEntity.h"
#include "../SGD Wrappers/SGD_Declarations.h"
#include "../SGD Wrappers/SGD_Handle.h"

class Entity : public IEntity
{
public:
	Entity() = default;
	virtual ~Entity() = default;

	//Entity types
	enum EntityType{ ENT_BASE, ENT_PLAYER, ENT_ENEMY, ENT_PROJECTILE, ENT_GRAPPLE, 
					ENT_PLANET, ENT_BOSS, ENT_WEAKPOINT, ENT_ORB, ENT_SHADOWMANCER };

	//Interface
	virtual void Update(float elapsedTime) override;
	virtual void Render() override;
	virtual const SGD::Rectangle GetRect() const override;
	virtual int GetType() const override { return ENT_BASE; }
	virtual void HandleCollision(const IEntity* other) override;
	virtual void CalculateRadius();

	//Final methods for reference counting
	virtual void AddRef() final;
	virtual void Release() final;

	//Accessors
	SGD::HTexture GetImage() const { return image; }
	SGD::Point GetPosition() const { return position; }
	SGD::Vector GetVelocity() const { return velocity; }
	SGD::Size GetSize() const { return size; }
	float GetRotation() const { return rotation; }
	float GetRadius() const { return radius; }
	SGD::Vector GetAcceleration() const {return Acceleration;}
	SGD::Vector GetForce() const {return Force;}
	float GetMass() const {return Mass;}
	int GetCollisionFlag() const { return collisionFlag; }

	//Mutators
	void SetImage(SGD::HTexture img){ image = img; }
	void SetPosition(SGD::Point pos){ position = pos; }
	void SetVelocity(SGD::Vector vel){ velocity = vel; }
	void SetSize(SGD::Size sz){ size = sz; }
	void SetRotation(float angle){ rotation = angle; }
	void SetAcceleration( SGD::Vector inaccel) { Acceleration = inaccel; }
	void SetForce(SGD::Vector inforce) { Force = inforce; }
	void SetMass(float inmass) { Mass = inmass; }
	void SetRadius(float r){ radius = r; }
	void SetCollisionFlag(int f){ collisionFlag = f; }

protected:
	SGD::HTexture image = SGD::INVALID_HANDLE; //sprite
	SGD::Point position = SGD::Point{ 0, 0 }; //2D position
	SGD::Vector velocity = SGD::Vector{ 0, 0 }; //2D velocity
	SGD::Size size = SGD::Size{ 0, 0 }; //2D size
	float rotation = 0.0f; //angle in radians
	float radius = 0.0f;
	SGD::Vector Acceleration = SGD::Vector{ 0, 0 };
	SGD::Vector Force = SGD::Vector{ 0, 0 };
	float Mass = 10;
	int collisionFlag = -1; //-1 means do not check collision

private:
	//reference count
	unsigned int refCount = 1;
};

